package com.xlh.virtualization.service;


import com.xlh.virtualization.po.FlavorUpdatePO;
import com.xlh.virtualization.po.ImageAllocationImageUpdatePO;
import com.xlh.virtualization.po.ImageAllocationUpdatePO;
import com.xlh.virtualization.vo.FlavorVO;
import com.xlh.virtualization.vo.ImageAllocationCourseVO;
import com.xlh.virtualization.vo.ImageAllocationTableVO;
import com.xlh.virtualization.vo.ImageAllocationVO;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;
import java.util.Map;

/**
 * @author cheer
 */
public interface ImageAllocationService {

    /**
     * 查询实验配置
     *
     * @param contextType 场景类型
     * @param contextId   场景Id
     * @return 实验配置
     */
    FlavorVO getFlavorByContext(Integer contextType, Long contextId);

    /**
     * 更新实验配置
     *
     * @param contextType    场景类型
     * @param contextId      场景Id
     * @param flavorUpdatePO 更新配置参数
     */
    void updateFlavorByContext(Integer contextType, Long contextId, FlavorUpdatePO flavorUpdatePO);

    /**
     * 查询镜像分配
     *
     * @param contextType 场景类型
     * @param contextId   场景Id
     */
    ImageAllocationVO getImageAllocation(Integer contextType, Long contextId);

    /**
     * 更新镜像分配
     *
     * @param contextType             场景类型
     * @param contextId               场景Id
     * @param imageAllocationUpdatePO 镜像分配参数
     */
    void updateImageAllocation(Integer contextType, Long contextId, ImageAllocationUpdatePO imageAllocationUpdatePO);

    /**
     * 删除镜像分配
     *
     * @param contextType 场景类型
     * @param contextId   场景Id
     */
    void deleteImageAllocation(Integer contextType, Long contextId);

    /**
     * 镜像分配更新镜像
     *
     * @param contextType                  场景类型
     * @param contextId                    场景Id
     * @param imageAllocationImageUpdatePO 镜像分配更新镜像参数
     */
    void updateImage(Integer contextType, Long contextId, ImageAllocationImageUpdatePO imageAllocationImageUpdatePO);

    /**
     * 查询课程镜像分配列表
     *
     * @param courseId 课程Id
     * @return 课程镜像分配列表
     */
    List<ImageAllocationCourseVO> listCourseImageAllocation(Long courseId);

    /**
     * 镜像是否已被分配
     *
     * @param imageId 镜像Id
     * @return 如果镜像已被分配返回true，否则返回false
     */
    Boolean isImageAllocated(Long imageId);

    /**
     * 拷贝镜像分配
     *
     * @param contextType     场景类型
     * @param sourceContextId 源场景Id
     * @param targetContextId 目标场景Id
     */
    void copyImageAllocation(Integer contextType, Long sourceContextId, Long targetContextId);

    /**
     * 物理删除镜像分配
     *
     * @param contextType 场景类型
     * @param contextId   场景Id
     */
    void trueDeleteImageAllocation(Integer contextType, Long contextId);

    void transport(Integer contextType, JdbcTemplate jdbcTemplate, Map<Long, Long> courseIdMap, Map<Long, Long> insertChapterMap, Map<Integer, Integer> iconMap);

    Map<Long, ImageAllocationTableVO> getTable(Integer contextType, List<Long> contextIds);

    /**
     * 查询已分配镜像的任务IDs
     * @param taskIds
     * @return
     */
    List<Long> getHaveImageTasks(List<Long> taskIds);


}
